
const getBaiduList = async (id) => {
  if(!window.utools)return[];
  let res = await window.utools.ubrowser
  .goto("https://top.baidu.com/board?tab=realtime")
  // .devTools('right')
  .wait('.rel .container', 60000)
  .wait(200)
  .evaluate(() => {
    let hotList = [...document.querySelectorAll('main.rel .container>div')[1].querySelectorAll(':scope > div')[1].querySelectorAll(':scope > div')];
    let arr = hotList.map((item, index) => {

      const infos = item.querySelectorAll(':scope > div');
      let url = infos[1].querySelector('a').href;
      let articleNumber = index + 1;
      let articleDetail = infos[1].querySelector('a').innerText;
      let hotNumber = infos[0].querySelectorAll(':scope > div')[1].innerText;

      return {
        url,
        index: articleNumber,
        detail: articleDetail,
        hot: hotNumber,
      };
    });
    return arr;
  })
  .run({ show: false });
  // .run({ width: 1300, height: 1000 });
  window.utools.clearUBrowserCache();
  return {
    id,
    list: res[0]
  }
};


export { getBaiduList };